package com.example.javascaffold.controller;


import com.example.javascaffold.annotation.Render;
import com.example.javascaffold.model.dto.AutoTestDTO;
import com.example.javascaffold.model.vo.AutoTestVO;
import com.example.javascaffold.service.AutoTestService;
import com.example.javascaffold.exception.BaseException;
import com.example.javascaffold.utils.DtoCheckUtils;
import com.example.javascaffold.utils.Ret;
import com.example.javascaffold.utils.RetPage;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

/**
* AutoTestController
* @author song
* @date 2022-05-30 09:05:43
* @param
* @return
* @other
**/
@Api(tags = "AutoTestController")
@RestController
@RequestMapping("/AutoTest")
@RequiredArgsConstructor
public class AutoTestController {

    private final AutoTestService autoTestServiceImpl;

    /**
    * 查询所有 AutoTest
    * @author song
    * @date 2022-05-30 09:05:43
    * @param autoTestDTO 传入的参数
    * @return Ret<?> 执行结果
    * @other
    * @throws BaseException
    **/
    @ApiOperation(value = "获取AutoTest")
    @Render
    @GetMapping("/getAutoTest")
    public Ret<RetPage<AutoTestVO>> getAutoTest(AutoTestDTO autoTestDTO) throws BaseException {
        DtoCheckUtils.check(autoTestDTO);
        return Ret.data(autoTestServiceImpl.getAutoTest(autoTestDTO));
    }

    /**
    * 新增数据 AutoTest
    * @author song
    * @date 2022-05-30 09:05:43
    * @param autoTestDTO 传入的参数
    * @return Ret<?> 执行结果
    * @other
    * @throws BaseException
    **/
    @ApiOperation(value = "新增AutoTest")
    @Render
    @PostMapping("/addAutoTest")
    public Ret<String> addAutoTest(AutoTestDTO autoTestDTO) throws BaseException {
        DtoCheckUtils.check(autoTestDTO);
        return Ret.data(autoTestServiceImpl.addAutoTest(autoTestDTO));
    }

    /**
    * 更新数据 AutoTest
    * @author song
    * @date 2022-05-30 09:05:43
    * @param autoTestDTO 传入的参数
    * @return Ret<?> 执行结果
    * @other
    * @throws BaseException
    **/
    @ApiOperation(value = "更新AutoTest")
    @Render
    @PutMapping("/updAutoTest")
    public Ret<String> updAutoTest(AutoTestDTO autoTestDTO) throws BaseException {
        DtoCheckUtils.check(autoTestDTO);
        return Ret.data(autoTestServiceImpl.updAutoTest(autoTestDTO));
    }

    /**
    * 删除数据 AutoTest
    * @author song
    * @date 2022-05-30 09:05:43
    * @param autoTestDTO 传入的参数
    * @return Ret<?> 执行结果
    * @other
    * @throws BaseException
    **/
    @ApiOperation(value = "删除AutoTest")
    @Render
    @DeleteMapping("/delAutoTest")
    public Ret<String> delAutoTest(AutoTestDTO autoTestDTO) throws BaseException {
        DtoCheckUtils.check(autoTestDTO);
        return Ret.data(autoTestServiceImpl.delAutoTest(autoTestDTO));
    }
}
